package com.itrident.loader.imlp;

import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.template.CustomLiveTemplateBase;
import com.itrident.loader.AbstractLoader;
import com.itrident.loader.Loader;
import com.itrident.loader.imlp.GenLoader;

import java.util.ArrayList;
import java.util.List;

/**
 * @author cxx
 * @create 2020-12-29 9:57
 **/
public class MultipleLoader extends AbstractLoader {

    private List<Loader> loaders = new ArrayList<> (5);

    public MultipleLoader(CustomLiveTemplateBase ctb) {
        super (ctb);
        loaders.add (new GenLoader (ctb));
        loaders.add (new FormatLoader (ctb));
    }

    @Override
    public List<LookupElement> load(String prefix) {
        List<LookupElement> list = new ArrayList<> (10);
        for (Loader loader : loaders) {
            list.addAll (loader.load (prefix));
        }
        return list;
    }
}
